/*
 * @FilePath: /three/vite.config.ts
 * 介绍:配置汇总文件
 */
import { defineConfig, loadEnv } from "vite";
import viteDevConfig from "./vite.dev.config";
import viteProdConfig from "./vite.prod.config";
import viteBaseConfig from "./vite.base.config";
import viteTestConfig from "./vite.test.config";

const envResolver = {
  production: () => ({ ...viteBaseConfig, ...viteProdConfig }), //生产环境
  development: () => ({ ...viteBaseConfig, ...viteDevConfig }), //开发环境
  test: () => ({ ...viteBaseConfig, ...viteTestConfig }), //测试环境
};

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), "VITE_");
  return {
    ...envResolver[mode](),
  };
});
